function ContractSearch() {
}
ContractSearch.inherit(Portlet);

ContractSearch.prototype.init = function (oComponent) {
    ContractSearch.base.init.call(this);
    this._component = oComponent;
}

ContractSearch.prototype.complete = function (oComponent) {
    this._searchTable = this._component.getElementById("searchTable");
    this._searchTable.queryAndDisplay();
    this._groupTable = this._component.getElementById("groupTable");
    this._submitBtn = this._groupTable.getElementById("submitBtn");
    this._queryForm = this._component.getElementById("queryForm");
}

ContractSearch.prototype.openInsertFrom = function(oControl){
    WinUtil.openDialog(this._groupTable.getHTML(),{
        title:"新增",
        width:"400px"
    });
    this._groupTable.setEnable();
    this._submitBtn.show();
}

ContractSearch.prototype.openDetailFrom = function(oControl){
    var oData = oControl.getParent().getRecord();
    WinUtil.openDialog(this._groupTable.getHTML(),{
        title:"详情",
        width:"400px"
    });
    this._groupTable.queryForm("/contract/selectbyid.do",{id:oData.id},true);
    this._groupTable.setDisable();
    this._submitBtn.hide();
}

ContractSearch.prototype.openUpdateFrom = function(oControl){
    var oData = oControl.getParent().getRecord();
    WinUtil.openDialog(this._groupTable.getHTML(),{
        title:"编辑",
        width:"400px"
    });
    this._groupTable.setEnable();
    this._submitBtn.show();
    this._groupTable.queryForm("/contract/selectbyid.do",{id:oData.id},true);
}

ContractSearch.prototype.submitGroup = function(oControl){
    debugger;
    var oData = oControl.getParent().getData();
    var url = "/contract/insert.do";
    if(oData.id){
        url = "/contract/update.do";
    }
    oControl.getParent().saveForm(url,true,function(oResult){
        if(oResult.record <= 0){
            WinUtil.showTip({title:"本次操作失败,请联系管理员"});
        }
    });
}

ContractSearch.prototype.delete = function(oControl){
    var that = this;
    var oData = oControl.getParent().getRecord();
    var soap = new HWSOAP("/contract/delete.do");
    soap.send({id:oData.id},true,function(oResult){
        if(oResult.record <= 0){
            WinUtil.showTip({title:"本次操作失败,请联系管理员"});
        }else{
            that._searchTable.queryAndDisplay();
        }
    });
}

ContractSearch.prototype.clearQueryForm = function(oControl){
    this._queryForm.clearForm();
}

ContractSearch.prototype.subimtQueryForm = function(oControl){
    var oData = this._queryForm.getData();
    this._searchTable.queryAndDisplay(oData);
}

/**
 * 注册方法
 */
ContractSearch.HANDLER = {}

ContractSearch.E_HANDLER = {
    "MSG_EXPORT_ALL": null
};
